package cn.bugstack.domain.activity.service.trial.Thread;

import cn.bugstack.domain.activity.adapter.repository.IActivityRepository;
import cn.bugstack.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import cn.bugstack.domain.activity.model.valobj.SCSkuActivityVO;

import java.util.concurrent.Callable;

/**
 * @author yjn
 * @description
 * @create 2025/8/10 15:55
 */
public class queryGroupBuyActivityDiscountVOThreadTask implements Callable<GroupBuyActivityDiscountVO> {

    private final String source;
    private final String channel;
    private final String goodsId;
    private final IActivityRepository repository;

    public queryGroupBuyActivityDiscountVOThreadTask(String channel, String source,String goodsId, IActivityRepository repository) {
        this.channel = channel;
        this.source = source;
        this.goodsId= goodsId;
        this.repository = repository;
    }

    @Override
    public GroupBuyActivityDiscountVO call() throws Exception {
        SCSkuActivityVO scSkuActivityVO= repository.querySCSkuActivityBySCGoodsId(source,channel,goodsId);
        if(null == scSkuActivityVO) return null;

        return repository.queryGroupBuyActivityDiscountVO(scSkuActivityVO.getActivityId());
    }
}
